<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        /*window.onload=function()
        {
            const btn1=document.getElementById("btn1");
            btn1.onclick=function()
            {
                fetch("http://127.0.0.1:8000/fetch-server",{
                    //请求方法
                    method:"POST",
                    //请求头
                    headers:{
                        name:"尚硅谷"
                    },
                    //请求体
                    body:"username=admin&password=admin"
                })
            };
        };*/
              
    </script>
</head>
<body>
    <button id="btn1">AJAX请求</button>
    <script>
        const btn1=document.querySelector("button");
            btn1.onclick=function()
            {
                fetch("http://127.0.0.1:8000/fetch-server",{
                    //请求方法
                    method:"POST",
                    //请求头
                    Headers:{
                        name:"尚硅谷"
                    },
                    //请求体
                    body:"username=admin&password=admin"
                }).then(Response=>{
                    return Response.json();
                }).then(Response=>{
                    console.log(Response);
                })
            };
    </script>
</body>
</html>